package com.example.langchain4j_springboot;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

    public class Main {
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
           int t= in.nextInt();
           for (int i=1;i<=t;i++){
               int n=in.nextInt();
               int k=in.nextInt();
               int[] arr=new int[n];
               HashMap<Integer,Integer> map=new HashMap<>();
               for (int j=0;j<n;j++){
                   arr[j]=in.nextInt();
                   if (map.containsKey(arr[j])){
                       map.put(arr[j],map.get(arr[j])+1);
                   }else {
                       map.put(arr[j],1);
                   }
               }
               if (arr.length==0){
                   System.out.println("Yes");
                   continue;
               }
               if (map.size()==1 && map.get(arr[0])>k){
                   System.out.println("No");
                   continue;
               }
               int count=0;
               for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
                   if (entry.getValue()<=1) continue;
                   if (entry.getValue()>=k){
                       count++;
                   }
               }
               if (count>1){
                   System.out.println("No");
               }else {
                   boolean flag=false;
                   for (int j=0;j<k;j++){
                       if (map.size()==arr.length-j){
                           System.out.println("Yes");
                           flag=true;
                           break;
                       }
                   }
                   if (!flag){
                       System.out.println("No");
                   }
               }
           }
        }
    }
